import Vue from 'vue'
import VueRouter from 'vue-router'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    component: () => import(/* webpackChunkName: "about" */ '../views/HomeView.vue'),
    redirect:'/login',
    children:[
      {
        path: 'index',
        name: '首页',
        component: () => import(/* webpackChunkName: "about" */ '../views/index.vue')
      },
      {
        path: 'user',
        name: '用户列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/user/User.vue')
      },
      {
        path: 'question',
        name: '试题列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/question/Question.vue')
      },
      {
        path: 'article',
        name: '文章列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/article/Article.vue')
      },
      {
        path: 'articleTag',
        name: '文章标签列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/tag/ArticleTag.vue')
      },
      {
        path: 'questionTag',
        name: '问题标签列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/tag/QuestionTag.vue')
      },
      {
        path: 'articleType',
        name: '文章类型列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/type/ArticleType.vue')
      },
      {
        path: 'questionType',
        name: '试题类型列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/type/QuestionType.vue')
      },
      {
        path: 'sentence',
        name: '名言列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/sentence/Sentence.vue')
      },
      {
        path: 'questionComment',
        name: '试题留言',
        component: () => import(/* webpackChunkName: "about" */ '../views/comment/QuestionComment.vue')
      },
      {
        path: 'articleComment',
        name: '文章留言',
        component: () => import(/* webpackChunkName: "about" */ '../views/comment/ArticleComment.vue')
      },
      {
        path: 'person',
        name: '个人信息',
        component: () => import(/* webpackChunkName: "about" */ '../views/user/Person.vue')
      },
      {
        path: 'updatePassword',
        name: '修改密码',
        component: () => import(/* webpackChunkName: "about" */ '../views/user/UpdatePassword.vue')
      },
      {
        path: 'userLog',
        name: '用户日志',
        component: () => import(/* webpackChunkName: "about" */ '../views/log/UserLog.vue')
      },
      {
        path: 'file',
        name: '文件列表',
        component: () => import(/* webpackChunkName: "about" */ '../views/file/File.vue')
      },
      {
        path: 'echarts',
        name: '数据报表',
        component: () => import(/* webpackChunkName: "about" */ '../views/echarts/Echarts.vue')
      }

    ]
  },
  {
    path: '/about',
    name: 'about',
    component: () => import(/* webpackChunkName: "about" */ '../views/AboutView.vue')
  },
  {
    path: '/login',
    name: 'Login',
    component: () => import(/* webpackChunkName: "about" */ '../views/user/Login.vue')
  },
  {
    path: '/register',
    name: 'Register',
    component: () => import(/* webpackChunkName: "about" */ '../views/user/Register.vue')
  }
]

const router = new VueRouter({
  mode: 'history',
  base: process.env.BASE_URL,
  routes
})

router.beforeEach((to, from, next)=>{
  next()
})

export default router
